home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 624 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: gryphon.phoenix.net!usenet
  2. From: brucew@phoenix.net (Bruce Wedding)
  3. Newsgroups: comp.lang.c,alt.msdos.programmer
  4. Subject: Re: Two strange C problems.
  5. Date: Mon, 08 Jan 1996 03:51:13 GMT
  6. Organization: BranPaul Systems
  7. Message-ID: <4cq1vu$d8c@gryphon.phoenix.net>
  8. References: <4cojb2$qog@lugb.latrobe.edu.au>
  9. NNTP-Posting-Host: dial133.phoenix.net
  10. X-Newsreader: Moe's Newsreader    
  11.  
  12. cs102238@lux.latrobe.edu.au (Gregary John Boyles ) wrote:
  13.  
  14. >I have two C problems.
  15.  
  16. Sorry, I don't feel like taking the time for problem #1.
  17.  
  18. >PROBLEM 2 :
  19.  
  20. >const escape=27;
  21. >const cr=13;
  22. >const bs=8;
  23.  
  24. In C++, this is ok.  In C, you have to use:
  25. #define ESC 27
  26. #define CR 13
  27.  
  28. etc.
  29.  
  30. >while (ch!=cr)
  31. Then all these loops will work.
  32.  
  33. >If I replace the 27 with \27' or the 13 with '\13' then these loops don't
  34. >work i.e. an infinite loop results. WHY?
  35.  
  36. Because the character will never equal those values, simple enough.
  37.  
  38. >Also if I want to do somthing like this : puts("\24 \25"); which should
  39. >print the up and down arrows on the screen (ASCII 24 and 25), but no, it
  40. >prints some other ASCII characters. As far as I can tell C has its own
  41. >unique character table, at least for the control characters. WHY?
  42.  
  43. It uses the standard ASCII character set, at least in DOS.  If you
  44. want to print those characters, just use those values.  The \
  45. character is only used with the following chars ( ",\,n,r,f,0).  Well,
  46. that is probably not all of them, but those are the most important.
  47. If you want to print those characters above, do this:
  48.  
  49. print("%c%c", 24,25);
  50. or 
  51. char a[3] = { 24, 25, '\0'};
  52. puts(a);
  53.  
  54. >Sometimes I wonder whether some one needs to go back an rewrite 
  55. >the damn language so that it works sensibly and predictably like 
  56. >Pascal can be relied upon to do.
  57.  
  58. I hate to say it, but you are asking for it.  Maybe one needs to learn
  59. the damn language so they can program sensibly and predictably.  At
  60. least there is a standard for C.  Pascal has no standard and will
  61. behave VERY unpredictably from system to system.
  62.  
  63.  
  64.  
  65. Bruce D. Wedding                        Have Compiler, Will Travel!
  66.               Perspicacious Programming Performed Promptly
  67. Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
  68.  
  69.